home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n10.arc / MARKDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  2KB  |  66 lines

  1. CodeBox:
  2.  
  3. MARKDEMO.PAS 
  4. COMPLETE LISTING
  5.  
  6.  
  7.  
  8.  
  9. PROGRAM MarkDemo;                 
  10.  
  11. TYPE
  12.  
  13.   BasePtr = ^Base;
  14.   Base = OBJECT                {NOTE: This declaration is identical }
  15.     DESTRUCTOR Done; virtual;  {to what's in Borland's OBJECTS.TPU. }
  16.   END;                         {If you use OBJECTS.TPU, omit it.    }
  17.  
  18.   Marker = RECORD END;
  19.  
  20.   NodeP = ^NodeO;
  21.   NodeO = OBJECT(Base)
  22.     Next : NodeP;        { You would not want to arbitrarily }
  23.     Prev : NodeP;        { clear these pointers! }
  24.     BeginData : Marker;  { Mark beginning of descendant's data items }
  25.     CONSTRUCTOR Init;
  26.   END;
  27.  
  28.   NameAddrO = OBJECT(NodeO)
  29.     Name  : STRING[30];
  30.     Addr  : STRING[30];
  31.     City  : STRING[20];
  32.     State : STRING[2];
  33.     Zip   : STRING[9];
  34.     PROCEDURE Show;
  35.     CONSTRUCTOR Init;
  36.   END;
  37.  
  38.   DESTRUCTOR Base.Done; BEGIN END;
  39.  
  40.   CONSTRUCTOR NodeO.Init;
  41.   BEGIN
  42.     Next := @self;        {Initialize pointers for circular list}
  43.     Prev := @self;
  44.     FillChar(BeginData, SizeOf(self)-SizeOf(NodeO), 0);
  45.   END;
  46.  
  47.   CONSTRUCTOR NameAddrO.Init; BEGIN NodeO.Init; END;
  48.  
  49.   PROCEDURE NameAddrO.Show;
  50.   BEGIN
  51.     WriteLn('Name [',Name,']' );
  52.     WriteLn('Addr [',Addr,']' );
  53.     WriteLn('City [',City,']  State [',State,']  Zip [',Zip,']' );
  54.   END;
  55.  
  56. VAR NameAddr : NameAddrO;
  57.  
  58. BEGIN
  59.   NameAddr.Init;
  60.   NameAddr.Show;
  61. END.
  62.  
  63.  
  64. Figure B: You can use FillChar to clear all of an object's data fields, but you have to avoid wiping out the VMT pointer.
  65.  
  66.